package main

import (
	"fmt"
	"gitee.com/zjlsliupei/gUploadFile"
	"gitee.com/zjlsliupei/ghelp"
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	app := gin.New()
	//gUploadFile.Init("local", `{"uploadDir":"uploads","groupPattern":"DATETIME::{2006};$CORPID$;DATETIME::{01-02}","maxSize":115048576, "allowExt":".jpg|.png|.ccx|.exe", "denyExt":".exe"}`)
	res := gUploadFile.Init("aliyunOss", `{"accessKey":"LTAI5t6Wngx37X2Auxr4sUCF","secret":"kyz2L5eQukcxLTYixJ7n8F4Y2og6JU","bucketName":"wensi-zhanlang","endPoint":"oss-cn-hangzhou.aliyuncs.com","prefix":"tmp","groupPattern":"DATETIME::{2006};$CORPID$","maxSize":1111048576,"allowExt":".ccx", "denyExt":".exe"}`)
	fmt.Println(res)
	app.POST("/", func(c *gin.Context) {
		form, _ := c.MultipartForm()
		files := form.File["file"]
		ff, err := gUploadFile.GetUploadFile().SaveUploadFiles(files, nil)
		if err != nil {
			c.String(http.StatusOK, err.Error())
			return
		}
		c.String(http.StatusOK, ghelp.JsonEncode(ff))
		return
	})
	app.Run(":8080")
}
